package com.chen.blue.controller.admin.common;

import com.chen.blue.result.R;
import com.chen.blue.service.redis.RedisKeysManager;
import com.chen.blue.utils.MinioUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;

/**
 * Created By CLT On 2024/4/28.
 */
@SuppressWarnings("all")
@Api(tags = "通用模块")
@Validated
@RestController
@RequestMapping("/common")
public class CommonController {

    /**
     * @param file
     * @param module
     * @param type   指的是某个流程在某个阶段的文件标识
     * @return
     */
    @ApiOperation(value = "文件上传", notes = "文件上传")
    @PostMapping("/upload")
    public R upload(@RequestParam("file") MultipartFile file, @RequestParam("module") String module, @RequestParam("type") Integer type) {

        return R.success(MinioUtil.upload(file, module, type));

    }

    @ApiOperation(value = "文件下载", notes = "文件下载")
    @GetMapping("/download")
    public void download(@RequestParam("path") String path, HttpServletResponse response) {

        MinioUtil.download(response, path);

    }

    @ApiOperation(value = "获取rediskeys", notes = "获取rediskeys")
    @GetMapping("/getRedisInfo")
    public R getRedisKeyValue() {

        return R.success(RedisKeysManager.getRedisKey());

    }

}
